home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / datacomm / vltjr / rexx / intercept.vlt < prev    next >
Text File  |  1995-03-17  |  1KB  |  49 lines

  1. /** Intercept.vlt
  2. *
  3. *   Example program to intercept keystrokes.
  4. *   Changes lower case b's into upper case C's, until you type a lower case a.
  5. *
  6. **/
  7.  
  8. /*
  9. *   Open a port
  10. */
  11. mp = openport(FOOBAR)
  12. "message (Now type some lower case b's and other stuff.*NType a lower case a to get out.)"
  13. /*
  14. *   Tell VLT to send us stuff
  15. */
  16. "wedge keystrokes FOOBAR"
  17. /*
  18. *   Loop until quitflag is 1, waiting for packets
  19. */
  20. do forever
  21.    if quitflag = 1 then leave
  22.    t = waitpkt(FOOBAR)
  23. /*
  24. *   We got a number of packets. Loop over all of them.
  25. */
  26.    do ff = 1
  27.       p = getpkt(FOOBAR)
  28.       if c2d(p) = 0 then leave ff
  29.       line = getarg(p)
  30. /*
  31. *   Got a line. It is of the form: KEYSTROKE code qualifier iaddress character
  32. *   parse it out.
  33. */
  34.       parse var line command code qual iaddr char .
  35. /*
  36. *   If we got an "a", quit. If a "b", say that we'll handle this one
  37. *   ourselves by replying a 0 error return and replace it with a capital C!
  38. *   Otherwise return a 1.
  39. */
  40.       if char = 'a' then quitflag = 1
  41.       if char = 'b' then do
  42.          t = reply(p, 0)
  43.          if (char = 'b') then address VLT "send (C); emit (C);"
  44.       end
  45.       else t = reply(p, 1)
  46.    end
  47. end
  48.  
  49.